package com.hqyj.controller;


import com.hqyj.pojo.TbDevice;
import com.hqyj.service.TbDeviceService;
import org.bouncycastle.crypto.tls.SRTPProtectionProfile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * <p>
 * 设备表 前端控制器
 * </p>
 *
 * @author gp
 * @since 2021-09-25
 */
@RestController
@RequestMapping("/tb-device")
public class TbDeviceController {
    @Autowired
    TbDeviceService tbDeviceService;
    /**
    * @Author:YaoHaoHong
    * @Description:
     * 查询设备
     *127.0.0.1:8080/tb-device/list
    * @Date:2021/10/8 11:23
    */
    @GetMapping(value = "/list")
    HashMap<String ,Object> list(TbDevice tbDevice){
        return tbDeviceService.list(tbDevice);
    }

    /**
    * @Author:YaoHaoHong
    * @Description:
     * 新增设备
    * @Date:2021/10/9 16:28
    */
    @PostMapping(value = "/add",consumes = "application/json")
    HashMap<String ,Object> insert(@RequestBody TbDevice tbDevice){
        return tbDeviceService.insert(tbDevice);
    }

    /**
    * @Author:YaoHaoHong
    * @Description:
     * 修改设备
    * @Date:2021/10/9 16:30
    */
    @PutMapping(value ="/update",consumes = "application/json")
    HashMap<String ,Object> update(@RequestBody TbDevice tbDevice){
        return tbDeviceService.update(tbDevice);
    }

    /**
    * @Author:YaoHaoHong
    * @Description:
     * 删除设备
    * @Date:2021/10/9 16:31
    */
    @DeleteMapping(value = "/del/{id}")
    HashMap<String ,Object> delete(@PathVariable Integer id){
        return tbDeviceService.delete(id);
    }

    /**
    * @Author:YaoHaoHong
    * @Description:
     * 按设备名称查询
    * @Date:2021/10/11 9:05
    */
    @GetMapping(value = "/queryByName/{name}")
    HashMap<String,Object> queryByName(@PathVariable String name){
        return tbDeviceService.queryByName(name);
    }
}

